<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改员工余额')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-WxUser-editBalance" th:object="${wxUser}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">员工号：</label>
            <div class="col-sm-8">
                <input name="number" th:field="*{number}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">姓名：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">手机号：</label>
            <div class="col-sm-8">
                <input name="iphone" th:field="*{iphone}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">当前余额：</label>
            <div class="col-sm-8">
                <input name="balance" th:field="*{balance}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">金额变更：</label>
            <div class="col-sm-8">
                <input name="balanceNew" class="form-control" oninput="value=value.replace(/[^\d]/g,'')" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "wechatprogram/WxUser"
    $("#form-WxUser-editBalance").validate({
        focusCleanup: true
    });
    // function submitHandler() {
    //     if ($.validate.form()) {
    //         $.operate.save(prefix + "/add", $('#form-WxUser-add').serialize());
    //     }
    // }

    // function submitHandler() {
    //     if ($.validate.form()) {
    //         var id = $("input[name=id]").val();
    //         var name = $("input[name=name]").val();
    //         var balanceOld = $("input[name=balance]").val();
    //         var balanceNew = $("input[name=balanceNew]").val();
    //         $.modal.confirm("确定将用户" + "("+name+")" + "的余额："+ balanceOld + "元，变更为：" + balanceNew + "元吗？", function () {
    //             $.ajax({
    //                 type: "post",
    //                 url: "/wechatprogram/WxUser/editBalanceSave",
    //                 data: {
    //                     "id": id,
    //                     "balance":balanceNew
    //                 },
    //                 success: function (r) {
    //                     if (r.code == 0) {
    //                         $(".code").val("");
    //                         $.modal.msg(r.msg);
    //                         $.modal.closeLoading();
    //                     } else {
    //                         $.modal.closeLoading();
    //                         $('.imgcode').click();
    //                         $(".code").val("");
    //                         $.modal.msg(r.msg);
    //                     }
    //                 }
    //             });
    //
    //         });
    //     }
    // }


    //保存信息 刷新表格
    function submitHandler(callback) {
            var id = $("input[name=id]").val();
            var name = $("input[name=name]").val();
            var balanceOld = $("input[name=balance]").val();
            var balanceNew = $("input[name=balanceNew]").val();
            $.modal.confirm("确定将用户" + "("+name+")" + "的余额："+ balanceOld + "元，变更为：" + balanceNew + "元吗？", function () {
                var config = {
                    url: prefix + "/editBalanceSave",
                    type: "post",
                    dataType: "json",
                    data: {
                        "id": id,
                        "balance":balanceNew
                    },
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                        $.modal.disable();
                    },
                    success: function (result) {
                        if (typeof callback == "function") {
                            callback(result);
                        }
                        $.operate.successCallback(result);
                    }
                };
            $.ajax(config)
        });
    }

</script>
</body>
</html>